let app = getApp();
Component({
  externalClasses: [
    'listbody-class',
    'listimage-class',
    'listtitle-class',
    'titlemain-class',
    'listarrow-class',
    'listicon-class',
    'iconarrow-class',
  ],
  properties: {
    extraList: {
      type: Array,
      value: [],
    },
    mode: {
      type: String,
      value: 'userPage',
    },
    imgType: {
      type: String,
      value: 'image',
    },
    iconColor: {
      type: String,
      value: '',
    },
    imgWidth: {
      type: Number,
      value: 80,
    },
    bottom: {
      type: String,
      value: '36vh',
    },
    full: {
      type: Boolean,
      value: false,
    },
  },
  data: {
    hiddenMenu: true,
  },
  methods: {
    getButlins() {
      let _this = this;
      app.util.request({
        url: 'auth/session/builtins',
        success: function (res) {
          if (Number(res.data.errno) === 0) {
            let builtins = res.data.data;
            _this.setData({ builtins });
          }
        },
        fail: function (err) {
          console.log(`builtins获取失败 ${err}`);
        },
      });
    },
    entrySubPackage(e) {
      const { path: url = '', name = '' } = e.currentTarget.dataset.item;
      app.util.navigateTo(url);
      this.setData({ hiddenMenu: true });
    },
    showMenu() {
      this.setData({ hiddenMenu: false });
    },
    hideMenu() {
      this.setData({ hiddenMenu: true });
    },
  },
  ready() {
    this.getButlins();
  },
});
